import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

import javax.swing.JPanel;


/**
 *
 * @author Bora SAYINER
 * @since Dec 21, 2014 10:13:45 AM
 * @version 1.0
 */
public class MyPanel extends JPanel {

	private int x = 0;
	private int y = 0;
	
	public MyPanel() {
		super();
	addMouseMotionListener(new MouseMotionListener() {
		
		@Override
		public void mouseMoved(MouseEvent e) {
			MyPanel.this.x = e.getX();
			MyPanel.this.y = e.getY();
			repaint();
		}
		
		@Override
		public void mouseDragged(MouseEvent e) {
			// TODO Auto-generated method stub
			
		}
	});
	}
	
	@Override
	public void paint(Graphics g) {
		super.paint(g);
		g.drawLine(0, 0, x, y);
//		Graphics2D graphics2d = (Graphics2D) g;
//		g.setColor(new Color(100, 50, 200));
//		g.drawLine(10, 10, 100, 100);
//		g.drawRect(50, 50, 100, 100);
//		g.drawOval(100, 100, 100, 100);
//		g.fillOval(300, 300, 200, 200);
//		g.drawString("Hello Java", 250, 250);
//		System.out.println("paint()");
		
	}
	
}
